<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>类型检测</title>
</head>

<body>
    <script>
        // typeof
        // var a = 1;
        // console.log(typeof a);   //number
        // var b = "1";
        // console.log(typeof b);   //string
        // var c;
        // console.log(typeof c);   //undefined
        // function fun() {}
        // console.log(typeof fun); //function
        // var d = [1, 2, 3, 4];
        // console.log(typeof d);   //object
        // var e = { name:'你好' };
        // console.log(typeof e);   //object

        // instanceof
        var m = [1,2,3];
        var n = {name:'你好'};
        function Arr(){}
        var r = new Arr();
        console.log(m instanceof Array);   //true
        console.log(n instanceof Array);   //false
        console.log(n instanceof Object);   //true
        console.log(Arr instanceof Function);  //true
        console.log(r instanceof Function);  //false
        console.log(r instanceof Arr);  //true

    </script>
</body>

</html>